package com.qf.weektest.MyTask;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.weektest.vo.ResultVo;
import com.qf.weektest.websocket.WebSocketServer;
import com.qf.weektest.weektest.entity.Tel;
import com.qf.weektest.weektest.service.ITelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.servlet.annotation.WebServlet;
import javax.websocket.Session;
import java.io.IOException;
import java.util.List;

@Component
public class MyTast {

    @Autowired
    WebSocketServer webSocketServer;
    @Autowired
    ITelService telService;

    @Scheduled(cron = "0/3 * * * * ? ")
    public void sendMsg() throws IOException {

        List<Tel> status = telService.list(new QueryWrapper<Tel>().eq("status", 1));

        int size = status.size();

        webSocketServer.sendMsg(size+"");



    }
}
